<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>菜单管理</title>
    <!-- 使用CDN引入CSS -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/datatables/1.10.21/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons-bs4/2.2.3/buttons.bootstrap4.min.css">
    <style>
        .card {
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }
        .card-header {
            background-color: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
            padding: 15px 20px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
        }
        .card-body {
            padding: 20px;
        }
        .status-active {
            color: #28a745;
            font-weight: bold;
        }
        .status-inactive {
            color: #dc3545;
            font-weight: bold;
        }
        .menu-level-0 {
            font-weight: bold;
        }
        .menu-level-1 {
            padding-left: 20px;
        }
        .menu-level-2 {
            padding-left: 40px;
        }
        .menu-level-3 {
            padding-left: 60px;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <h2 class="mt-4 mb-4">菜单管理</h2>
        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-search mr-1"></i>查询条件
            </div>
            <div class="card-body">
                <div class="row mb-4">
                    <div class="col-md-3">
                        <div class="form-group">
                            <label for="menuName">菜单名称</label>
                            <input type="text" class="form-control" id="menuName" placeholder="输入菜单名称">
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="form-group">
                            <label for="status">状态</label>
                            <select id="status" class="form-control">
                                <option value="">全部</option>
                                <option value="0">正常</option>
                                <option value="1">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="form-group">
                            <label>&nbsp;</label>
                            <button type="button" class="btn btn-primary btn-block" id="searchBtn">
                                <i class="fas fa-search"></i> 查询
                            </button>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="form-group">
                            <label>&nbsp;</label>
                            <button type="button" class="btn btn-secondary btn-block" id="resetBtn">
                                <i class="fas fa-redo"></i> 重置
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="card mb-4">
            <div class="card-header">
                <div class="row">
                    <div class="col-md-6">
                        <i class="fas fa-sitemap mr-1"></i>菜单列表
                    </div>
                    <div class="col-md-6 text-right">
                        <button type="button" class="btn btn-primary btn-sm" id="addBtn">
                            <i class="fas fa-plus"></i> 新增菜单
                        </button>
                        <button type="button" class="btn btn-success btn-sm ml-2" id="expandAllBtn">
                            <i class="fas fa-expand-arrows-alt"></i> 展开/折叠
                        </button>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table id="menuTable" class="table table-bordered" width="100%" cellspacing="0">
                        <thead>
                            <tr>
                                <th>菜单名称</th>
                                <th>图标</th>
                                <th>排序</th>
                                <th>权限标识</th>
                                <th>路径</th>
                                <th>类型</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <!-- 表格数据将通过JavaScript动态生成 -->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 菜单详情模态框 -->
    <div class="modal fade" id="menuModal" tabindex="-1" role="dialog" aria-labelledby="menuModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="menuModalLabel">菜单详情</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div id="menuDetails">
                        <!-- 菜单详情将通过JavaScript动态生成 -->
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 新增/编辑菜单模态框 -->
    <div class="modal fade" id="addEditMenuModal" tabindex="-1" role="dialog" aria-labelledby="addEditMenuModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="addEditMenuModalLabel">新增菜单</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="menuForm">
                        <input type="hidden" id="menuId" name="menuId">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalMenuType">菜单类型</label>
                                    <select class="form-control" id="modalMenuType" name="modalMenuType">
                                        <option value="M">目录</option>
                                        <option value="C">菜单</option>
                                        <option value="F">按钮</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalParentId">上级菜单</label>
                                    <select class="form-control" id="modalParentId" name="modalParentId">
                                        <option value="0">主目录</option>
                                        <!-- 上级菜单选项将通过JavaScript动态生成 -->
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalMenuName">菜单名称 <span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="modalMenuName" name="modalMenuName" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalOrderNum">显示排序 <span class="text-danger">*</span></label>
                                    <input type="number" class="form-control" id="modalOrderNum" name="modalOrderNum" required>
                                </div>
                            </div>
                        </div>
                        <div class="row" id="iconRow">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalIcon">菜单图标</label>
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text"><i id="iconPreview" class="fas fa-bars"></i></span>
                                        </div>
                                        <input type="text" class="form-control" id="modalIcon" name="modalIcon" placeholder="例如：fa fa-home">
                                        <div class="input-group-append">
                                            <button class="btn btn-outline-secondary" type="button" id="selectIconBtn">选择</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6" id="pathRow">
                                <div class="form-group">
                                    <label for="modalPath">路由地址</label>
                                    <input type="text" class="form-control" id="modalPath" name="modalPath" placeholder="例如：/system/user">
                                </div>
                            </div>
                        </div>
                        <div class="row" id="componentRow">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalComponent">组件路径</label>
                                    <input type="text" class="form-control" id="modalComponent" name="modalComponent" placeholder="例如：system/user/index">
                                </div>
                            </div>
                            <div class="col-md-6" id="permRow">
                                <div class="form-group">
                                    <label for="modalPerms">权限标识</label>
                                    <input type="text" class="form-control" id="modalPerms" name="modalPerms" placeholder="例如：system:user:list">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="modalStatus">状态</label>
                                    <select class="form-control" id="modalStatus" name="modalStatus">
                                        <option value="0">正常</option>
                                        <option value="1">停用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6" id="visibleRow">
                                <div class="form-group">
                                    <label for="modalVisible">显示状态</label>
                                    <select class="form-control" id="modalVisible" name="modalVisible">
                                        <option value="0">显示</option>
                                        <option value="1">隐藏</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="modalRemark">备注</label>
                                    <textarea class="form-control" id="modalRemark" name="modalRemark" rows="3"></textarea>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="saveMenuBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 使用CDN引入JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables/1.10.21/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons/2.2.3/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons/2.2.3/js/buttons.html5.min.js"></script>
    
    <!-- 引入菜单管理页面的JavaScript文件 -->
    <script th:src="@{/js/system/menu.js}"></script>
</body>
</html> 